package com.freesky.web.manager.controller.system;

import com.freesky.common.pojo.DataTablesResult;
import com.freesky.common.utils.reponse.JSONResponse;
import com.freesky.common.utils.reponse.JSONResponseDiretor;
import com.freesky.web.manager.service.ISystemLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author: 陈玉林
 * @modifiedBy:
 * @date: Create In 14:58 2019-01-11
 * @description:
 */
@Controller
@Api(description = "系统日志")
public class SystemLogController {
    @Autowired
    private ISystemLogService systemLogService;

    @GetMapping("/system/log/page")
    @ApiOperation(value = "进入页面-系统日志")
    public String logPage() {
        return "system/log";
    }
    @ResponseBody
    @GetMapping(value = "/system/log/list")
    @ApiOperation(value = "分页获取系统日志")
    public DataTablesResult getLog(
            @RequestParam(value = "draw") int draw,
            @RequestParam(value = "start") int start,
            @RequestParam(value = "length")int length,
            @RequestParam(value = "search[value]") String search) {
        return systemLogService.getLogList(draw, start, length, search);
    }

    @ResponseBody
    @GetMapping(value = "/system/log/count")
    @ApiOperation(value = "获取系统日志总数")
    public JSONResponse countLog() {
        return systemLogService.countLog();
    }

    @ResponseBody
    @DeleteMapping(value = "/system/log/del/{ids}")
    @ApiOperation(value = "删除系统日志")
    public JSONResponse deleteLog(@PathVariable int[] ids) {
        return systemLogService.deleteLog(ids);
    }

}
